@extends('admin.layout')
@section('title','用户列表')
@section('content')
    <div class="app_content_div" id="app_content_div_301Index">
        <h3>列表</h3>
    </div>

    <div>
        <div style="float:right;">
            <a type="button" class="btn btn-primary" href="user/create">新增</a>
        </div>
    </div>
    <table class="table table-striped">
        <thead>
        <tr>
            <th>id</th>
            <th>用户名</th>
            <th>更改密码</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($oUsers as $v)
            <tr>
                <th scope="row">{{$v->id}}</th>
                <td>{{$v->name}}</td>

                <td><a style="cursor:pointer;" href="user/edit-user/{{$v->id}}">更改密码</a></td>
                <td>
                    <form action="/adm/user/{{$v->id}}" method="post">
                        <input type="hidden" name="_method" value="DELETE">
                        {{csrf_field()}}
                        <a><button type="submit" class="glyphicon glyphicon-trash" aria-hidden="true"></button></a>
                    </form>
{{--                    <input type="hidden" name="_method" value="DELETE">--}}
{{--                    <a href="#"  onclick="delUser({{$v->id}})"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>--}}

{{--                    <a onclick="delUser({{$v->id}})"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>--}}
                </td>


            </tr>
        @endforeach


        </tbody>
    </table>

    {{$oUsers->links('admin.page')}}
@endsection
<script>
    function delUser(id){
        var conf = confirm('你确定要删除ID值为'+id+'的记录吗？');
        if(conf==true){
            $.ajax({
                url:'/adm/user/'+id,
                type:'DELETE',
                dataType:'json',
                data:{'_token':'{{csrf_token()}}'},
                success:function (data){
                    alert('删除成功');
                    location.href='/adm/user';
                },
                error:function (data){}
            });
        }}
</script>
